export const schema = {
    type: "page",
    title: "志愿者导入",
    body: {
        type: 'form',
        title: '',
        api: 'post:/api/volunteer/import',
        actions: [{
            type: 'submit',
            label: '导入',
            primary: true,
            feedback: {
                title: '导入结果',
                size: 'lg',
                actions: [
                    {
                        type: 'button',
                        label: '关闭',
                        actionType: 'cancel'
                    },
                    {
                        visibleOn: 'data.errors.length',
                        type: 'button',
                        label: '导出错误数据',
                        level: 'info',
                        actionType: 'ajax',
                        api: {
                            method: 'post',
                            type: 'blob',
                            url: '/api/volunteer/export',
                            data: {
                                i: '${errors}'
                            }
                        }
                    }
                ],
                body: [
                    {
                        type: 'tpl',
                        className: 'alert alert-info',
                        tpl: '导入成功！导入${saved}条，总跳过：${skiped}条，重复跳过${duplicated}条',
                        visibleOn: '!data.errors.length'
                    },
                    {
                        type: 'tpl',
                        className: 'alert alert-warning',
                        tpl: '导入成功，但存在${errors.length}条错误数据如下！导入${saved}条，总跳过：${skiped}条，重复跳过${duplicated}条。',
                        visibleOn: 'data.errors.length'
                    },
                    {
                        type: 'table',
                        visibleOn: 'data.errors.length',
                        rows: '${errors}',
                        columns: [
                            {
                                label: '姓名',
                                name: 'real_name'
                            },
                            {
                                label: '民族',
                                name: 'nation'
                            },
                            {
                                label: '身份证号',
                                name: 'id_number'
                            },
                            {
                                label: '手机',
                                name: 'phone'
                            },
                            {
                                label: '邮箱',
                                name: 'email'
                            }
                        ]
                    }
                ]
            }
        }],
        fieldSet: [
            {
                title: '第一步',
                controls: [
                    [
                        {
                            type: 'tpl',
                            className: 'm-b',
                            inline: true,
                            tpl: '请下载志愿者信息模板，批量填写志愿者信息。'
                        },
                        {
                            type: 'button',
                            label: '下载',
                            size: 'xs',
                            level: 'info',
                            actionType: 'url',
                            inline: true,
                            url: __uri('./导入模板.xls')
                        }
                    ]
                ]
            },
            {
                title: '第二步',
                controls: [
                    {
                        label: '上传填写好的志愿者信息表',
                        required: true,
                        type: 'file',
                        name: 'file',
                        accept: 'application/vnd.ms-excel'
                    }
                ]
            },
            {
                title: '第三步',
                controls: [
                    {
                        type: "select",
                        name: "org_id",
                        label: "所属机构",
                        source: "/api/org/sug?_=${_}",
                        required: true,
                        width: 200,
                        visibleOn: "!data.query.org_id && !acl.can('skip:select-org')"
                    },
                    {
                        label: '请选择志愿者所属团队',
                        type: 'select',
                        name: 'teamId',
                        width: 200,
                        source: '/api/team/sug?org_id=${org_id}&do_not_filter_auth_create_team=1'
                    }
                ]
            }
        ]
    }
};
